package com.zst.springbootjsonintegrationdemo.converter;

import com.alibaba.fastjson.JSON;

import javax.persistence.AttributeConverter;
import java.util.List;

public class ListToJsonStringConverter implements AttributeConverter<List, String> {
    @Override
    public String convertToDatabaseColumn(List list) {
        return JSON.toJSONString(list);
    }

    @Override
    public List convertToEntityAttribute(String s) {
        return JSON.parseArray(s).toJavaObject(List.class);
    }
}
